//
//  ArtTopicDetailListViewCell.m
//  ArtOfLiving
//
//  Created by 王文晓 on 16/4/30.
//  Copyright © 2016年 刘虎. All rights reserved.
//

#import "ArtTopicDetailListViewCell.h"
#import "ArtTopicListModel.h"
#import "ArtTopDataModel.h"

@interface ArtTopicDetailListViewCell ()

@property (weak, nonatomic) IBOutlet UILabel *titleLabel;

@property (weak, nonatomic) IBOutlet UILabel *categoryLabel; //开胃
@property (weak, nonatomic) IBOutlet UILabel *durationLabel; //分钟

@property (weak, nonatomic) IBOutlet UIImageView *backImageView;


@end



@implementation ArtTopicDetailListViewCell

- (void)setCellWithModel:(id)model{
    
    if ([model isKindOfClass:[ArtTopicListModel class]]) {
        
        ArtTopicListModel *ListModel = model;
        SDWebImageOptions options = SDWebImageRetryFailed | SDWebImageLowPriority;
        [self.backImageView sd_setImageWithURL:[NSURL URLWithString:ListModel.image] placeholderImage:[UIImage imageNamed:@"artPlacehoder.png"] options:options];
        self.titleLabel.hidden = YES;
        self.durationLabel.hidden = YES;
        self.categoryLabel.hidden = YES;
    }
    
    else if ([model isKindOfClass:[ArtTopDataModel class]]) {
        
        self.titleLabel.hidden = NO;
        self.durationLabel.hidden = NO;
        self.categoryLabel.hidden = NO;
        ArtTopDataModel *DataModel = model;
        SDWebImageOptions options = SDWebImageRetryFailed | SDWebImageLowPriority;
        [self.backImageView sd_setImageWithURL:[NSURL URLWithString:DataModel.coverModel.feed] placeholderImage:[UIImage imageNamed:@"artPlacehoder.png"] options:options];
        self.titleLabel.text = DataModel.title;
        self.durationLabel.text = [NSString stringWithFormat:@"%@",DataModel.duration];
        NSInteger time = [self.durationLabel.text intValue];
        NSInteger min = time/60; //获取分数
        NSInteger sec = time%60; //获取秒数
        NSString *timeStr = [NSString stringWithFormat:@"%02ld':%02ld''",min,sec];
        self.durationLabel.text = timeStr;
        self.categoryLabel.text = [NSString stringWithFormat:@"#%@",DataModel.category];


}
    
}


















@end
